#include "calc.h"

// see calc.h
template <class T>
Calc<T>::Calc() {
    matrixA = NULL;
    matrixB = NULL;
}
template Calc<int>::Calc();

// see calc.h
template <class T>
Calc<T>::~Calc() {
    if (matrixA != NULL) { delete matrixA; }
    if (matrixB != NULL) { delete matrixB; }
}
template Calc<int>::~Calc();

// see calc.h
template <class T>
void Calc<T>::setMatrixA(Matrix<T>* matrix) {
    matrixA = matrix;
}
template void Calc<int>::setMatrixA(Matrix<int>* matrix);

// see calc.h
template <class T>
void Calc<T>::setMatrixB(Matrix<T>* matrix) {
    matrixB = matrix;    
}
template void Calc<int>::setMatrixB(Matrix<int>* matrix);

// see calc.h
template <class T>
void Calc<T>::setOperation(int op) {
    operation = op;    
}
template void Calc<int>::setOperation(int op);

// see calc.h
template <class T>
void Calc<T>::execute() {
    Matrix<T> result;
    switch (operation) {
        case 1:
            cout << "Operation 1 is addition, ";
            result = *matrixA + *matrixB;
            cout << "Result matrix is: \n" << result;
            break;
        case 2:
            cout << "Operation 2 is subtraction, ";
            result = *matrixA - *matrixB;
            cout << "Result matrix is: \n" << result;
            break;
        case 3:
            cout << "Operation 4 is multiplication, ";
            result = *matrixA * *matrixB;
            cout << "Result matrix is: \n" << result;
            break;
        case 4:
            cout << "Operation 4 is increment (++), ";
            cout << "Result matrix is: \n";
            (*matrixA)++;
            cout << *matrixA;
            break;
        case 5:
            cout << "Operation 5 is decrement (--), ";
            cout << "Result matrix is: \n";
            (*matrixA)--;
            cout << *matrixA;
            break;
        case 6:
            cout << "Operation 6 is print, matrix is: \n";
            result = *matrixA;
            cout << result;
            break;
        default:
            break;
    }
}
template void Calc<int>::execute();
